class FingersController < ApplicationController
  before_action :set_task, only: [:index]

  def index
    @fingers = @task.fingers.valid.to_a + @task.fingers.invalid.to_a + @task.fingers.suspect.to_a + @task.fingers.pending.to_a
    @fingers = Kaminari.paginate_array(@fingers).page(params[:page])
  end

  def show
    @finger = Finger.find(params[:id])
  end

  def mark
    @finger = Finger.find(params[:id])
    marker = params[:marker]
    @finger.update_attributes(marker: marker)
    if marker == 'pending'
      @finger.reset
    end

    redirect_to :back
  end

  private
  def set_task
    @task = Task.find(params[:id])
  end
end
